package org.sikyon.chocolatebiscuit.datamarket;

import org.sikyon.chocolatebiscuit.datamarket.inmemory.InMemoryMarket;
import org.sikyon.chocolatebiscuit.model.entities.Identifiable;

/**
 * Represents the whole data market for the Chocolate Biscuit app, that is, the whole object graph of persistent
 * objects.
 * <p/>
 * Has methods that handle thread-safe singletons for the stores of every persistent type.
 */
public interface Market {

    // auxiliary methods while I put in an IoC container
    Market inMemory = new InMemoryMarket();

    /**
     * Returns the right Store for the given class type.
     *
     * @param <T> The entity's type.
     * @param <K> The entity's key type.
     */
    public <T extends Identifiable<K>, K> Store<T, K> getStoreFor(Class<T> clazz);
}
